array mathematics hackerrank solution